<?php
require_once 'Zend/Controller/Action.php';

class ReporteAlumno_IndexController extends Zend_Controller_Action {

	public function preDispatch() {
		$auth = Zend_Auth :: getInstance();
		if (!$auth->hasIdentity()) {
			$this->_redirect('acceso/auth/login');
		}
		$zend_acl = Gea_Zend_Acl_Factory :: getInstance();
		if (!$zend_acl->isAllowed($auth->getIdentity()->ROL_ID, $this->getRequest()->getModuleName())) {
			$this->_redirect('/');
		}
	}

	public function init() {
		$registry = Zend_Registry :: getInstance();
		$this->smarty = $registry->smarty;
		$this->smarty->assign('baseUrl', $this->getRequest()->getBaseUrl());
		$this->smarty->assign('moduleName', $this->getRequest()->getModuleName());
		$this->smarty->assign('controllerName', $this->getRequest()->getControllerName());
		$this->smarty->assign('actionName', $this->getRequest()->getActionName());
		$this->smarty->assign('subtitulo', 'Reporte Alumnos');
	}

	public function indexAction() {

		$registry = Zend_Registry :: getInstance();
		$config = $registry->config;
		$idUsuario = Zend_Auth :: getInstance()->getIdentity()->USUARIO_ID;
		$db = Zend_Db :: factory('Mysqli', array (
			'host' => $config->database->host,
			'username' => $config->database->username,
			'password' => $config->database->password,
			'dbname' => $config->database->name
		));
		$rs = $db->fetchAll('SELECT EXU.EXAMEN_USUARIO_DATE AS EXAMEN_USUARIO_DATE, EX.EXAMEN_NOMBRE AS EXAMEN_ID FROM EXAMEN_USUARIO EXU INNER JOIN EXAMEN EX ON EX.EXAMEN_ID = EXU.EXAMEN_ID WHERE EXU.USUARIO_ID = ' . $idUsuario);
		$this->smarty->assign('examenes', $rs);
		$this->smarty->displayInMasterPage('reporteAlumno_index_index.tpl', 'masterPage.tpl');
	}
}
?>
